﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">

    <meta name="description" content="Write an awesome description
		for your new site here. You can edit this line in _config.yml.
		It will appear in your document head meta (for Google search results)
		and in your feed.xml site description.
		">
    <title></title>

    <link rel="stylesheet" href="../lib/weui.min.css">
    <link rel="stylesheet" href="../css/jquery-weui.css">
    <link rel="stylesheet" href="../css/demos.css">
    <script src="../lib/jquery-2.1.4.js"></script>
    <script src="../lib/fastclick.js"></script>
    <script src="../js/jquery-weui.js"></script>
    <script src="../js/city-picker.js"></script>
    <script src="../js/weui.min.js"></script>
    <script src="https://pv.sohu.com/cityjson?ie=utf-8"></script>
    <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script>
        function getQueryString(param) { //param为要获取的参数名 注:获取不到是为null
            var currentUrl = window.location.href; //获取当前链接
            var arr = currentUrl.split("?");//分割域名和参数界限
            if (arr.length > 1) {
                arr = arr[1].split("&");//分割参数
                for (var i = 0; i < arr.length; i++) {
                    var tem = arr[i].split("="); //分割参数名和参数内容
                    if (tem[0] == param) {
                        return tem[1];
                    }
                }
                return null;
            }
            else {
                return null;
            }
        }

        var pageParam = {};
        var ticket = "";
        var openId = "";
        var price = 0;
        window.onload = function () {
            $.ajax({
                url: "/event/information/isAble?id=" + ${eventId},
                method: "post",
                dataType: "json",

                contentType: "application/json",
                success: function (res) {
                    if (res.status == 0) {
                        alert(res.msg);
                        var userAgent = navigator.userAgent;
                        if (userAgent.indexOf("Firefox") != -1 || userAgent.indexOf("Chrome") != -1) {
                            document.addEventListener('WeixinJSBridgeReady', function () {
                                WeixinJSBridge.call('closeWindow');
                            }, false)
                        } else {
                            setTimeout(function () {
                                WeixinJSBridge.invoke("closeWindow", {}, function (e) {
                                })
                            }, 100)
                        }
                    }
                }
            });
            $(".participantCode_show").hide()
            $(".reference_show").hide()
            $(".event_price_show").hide()
            openId = window.localStorage.getItem("openid");
            if (undefined == openId || null == openId || "" == openId || "null" == openId) {
                let code = getQueryString("code");
                if (null != code && undefined != code && "" != code) {
                    $.ajax({
                        url: "/wx/getOpenIdByCode?code=" + code,
                        method: "get",
                        success: function (res) {
                            if (res.status === 1) {
                                window.sessionStorage.setItem("openid", res.data.openid);
                                window.localStorage.setItem("openid", res.data.openid);
                                $.ajax({
                                    url: "/wx/getTicket",
                                    method: "get",
                                    async: false,
                                    success: function (res) {
                                        if (res.status === 1) {
                                            ticket = res.data;
                                        }
                                    }
                                })
                            }
                            else{
                                let currentUrl = window.location.href;
                                $.ajax({
                                    url: "/wx/auth?redirectUrl=" + currentUrl,
                                    method: "get",
                                    success: function (url) {
                                        window.location.href = url;
                                    }
                                })
                            }
                        }
                    })
                }
                else {
                    let currentUrl = window.location.href;
                    $.ajax({
                        url: "/wx/auth?redirectUrl=" + currentUrl,
                        method: "get",
                        success: function (url) {
                            window.location.href = url;
                        }
                    })
                }
            }
            $(".add_team_show").hide();
            var eventId = ${eventId}
                    $.ajax({
                        url: "/participant/page/param/get/by/eventId?eventId=" +${eventId},
                        method: "post",
                        dataType: "json",
                        async: false,
                        contentType: "application/json",
                        success: function (res) {
                            if (res.status == 1) {
                                let parse = JSON.parse(res.data.paramJson);
                                pageParam = parse;
                                if (!parse.teamId) {
                                    $(".teamId_show").hide();
                                }
                                if (!parse.roleId) {
                                    $(".roleId_show").hide();
                                }
                                if (!parse.nationality) {
                                    $(".nationality_show").hide();
                                }
                                if (!parse.birthday) {
                                    $(".birthday_show").hide();
                                }
                                if (!parse.bloodType) {
                                    $(".bloodType_show").hide();
                                }
                                if (!parse.clothingSize) {
                                    $(".clothingSize_show").hide();
                                }
                                if (!parse.country) {
                                    $(".country_show").hide();
                                }
                                if (!parse.nation) {
                                    $(".nation_show").hide();
                                }
                                if (!parse.passedPhysicalExam) {
                                    $(".passedPhysicalExam_show").hide();
                                }
                                if (!parse.trainingMileage) {
                                    $(".trainingMileage_show").hide();
                                }
                                if (!parse.reference) {
                                    $(".reference_show").hide();
                                }

                                if (!parse.email) {
                                    $(".email_show").hide();
                                }
                                if (!parse.occupation) {
                                    $(".occupation_show").hide();
                                }
                                if (!parse.education) {
                                    $(".education_show").hide();
                                }

                                if (!parse.companyName) {
                                    $(".company_name_show").hide();
                                }
                                if (!parse.companyPosition) {
                                    $(".company_position_show").hide();
                                }
                                if (!parse.eventsInRecentYear) {
                                    $(".events_in_recent_year_show").hide();
                                }
                                if (!parse.bestResult) {
                                    $(".best_result_show").hide();
                                }
                                if (!parse.pic) {
                                    $(".file_show").hide();
                                }
                                if (!parse.alumniRelationPersion) {
                                    $(".alumni_relation_persion_show").hide();
                                }
                                if (!parse.alumniId) {
                                    $(".alumni_id_show").hide();
                                }

                            }
                        }
                    });
            $.ajax({
                url: "/event/group/list?eventId=" +${eventId},
                method: "post",
                dataType: "json",
                async: false,
                contentType: "application/json",
                success: function (res) {
                    let groups = [] = res.data;
                    groupList = groups;
                    if (groups.length !== 0) {
                        for (let i = 0; i < groups.length; i++) {
                            if (i === 0) {
                                $("#group_content").append(
                                        ' <label class="weui-cell weui-check__label" for="x' + i + 1 + '">' +
                                        '        <div class="weui-cell__hd">' +
                                        '            <input type="radio" name="group_id" class="weui-check" id="x' + i + 1 + '" value="' + groups[i].id + '"checked=checked" />' +
                                        '            <span class="weui-icon-checked"></span>' +
                                        '        </div>' +
                                        '        <div class="weui-cell__bd">' +
                                        '            <p>' + groups[i].name + '</p>' +
                                        '        </div>' +
                                        '</label>'
                                )
                            }
                            else {
                                $("#group_content").append(
                                        ' <label class="weui-cell weui-check__label" for="x' + i + 1 + '">' +
                                        '        <div class="weui-cell__hd">' +
                                        '            <input type="radio" name="group_id" class="weui-check" id="x' + i + 1 + '" value="' + groups[i].id + '" />' +
                                        '            <span class="weui-icon-checked"></span>' +
                                        '        </div>' +
                                        '        <div class="weui-cell__bd">' +
                                        '            <p>' + groups[i].name + '</p>' +
                                        '        </div>' +
                                        '</label>'
                                )
                            }
                        }
                    }
                }
            });
            $.ajax({
                url: "/participant/team/list/by/eventId?eventId=" +${eventId},
                method: "post",
                dataType: "json",
                async: false,
                contentType: "application/json",
                success: function (res) {
                    if (undefined == res.data) {
                        return;
                    }
                    let teams = [] = res.data;

                    let items = []
                    if (teams.length !== 0) {

                        for (let i = 0; i < teams.length; i++) {
                            let item = {}
                            item.title = teams[i].name
                            item.value = teams[i].id
                            items.push(item)
                        }
                    }
                    $("#team_id").select({
                        title: "选择团队",
                        items: items,
                        onChange: function (d) {
                        },
                        onClose: function () {
                        },
                        onOpen: function () {
                        },
                    });
                }
            });
            $.ajax({
                url: "/alumniAssociation/list",
                method: "post",
                dataType: "json",
                async: false,
                contentType: "application/json",
                success: function (res) {
                    let teams = [] = res.data;

                    let items = []
                    if (teams.length !== 0) {

                        for (let i = 0; i < teams.length; i++) {
                            let item = {}
                            item.title = teams[i].name
                            item.value = teams[i].id
                            items.push(item)
                        }
                    }
                    $("#alumni_id").select({
                        title: "选择校友会",
                        items: items,
                        onChange: function (d) {
                        },
                        onClose: function () {
                        },
                        onOpen: function () {
                        },
                    });
                }
            })
            $.ajax({
                url: "/applicationRoles/list",
                method: "post",
                dataType: "json",
                async: false,
                contentType: "application/json",
                success: function (res) {
                    let teams = [] = res.data;

                    let items = []
                    if (teams.length !== 0) {

                        for (let i = 0; i < teams.length; i++) {
                            let item = {}
                            item.title = teams[i].name
                            item.value = teams[i].id
                            items.push(item)
                        }
                    }
                    $("#role_id").select({
                        title: "选择角色",
                        items: items,
                        onChange: function (d) {
                        },
                        onClose: function () {
                        },
                        onOpen: function () {
                        },
                    });
                }
            })
            $.ajax({
                url: "/event/price/list?eventId=" +${eventId},
                method: "post",
                dataType: "json",

                contentType: "application/json",
                success: function (res) {
                    let teams = [] = res.data;

                    let items = []
                    if (teams.length !== 0) {

                        for (let i = 0; i < teams.length; i++) {
                            let item = {}
                            item.title = teams[i].name
                            item.value = teams[i].id
                            item.price = teams[i].price
                            items.push(item)
                        }
                    }

                    $("#event_price_id").val(teams[0].name)
                    $("#event_price_id").attr("data-values", teams[0].id)

                    $("#event_price_id").select({
                        title: "选择套餐",
                        items: items,
                        onChange: function (change) {
                        },
                        onClose: function (close) {
                            price = close.data.origins[0].price;
                            console.log(price)


                            // if (price == 0) {
                            //     $(".document_show").hide()
                            // } else {
                            //     $(".document_show").show()
                            // }
                        },
                        onOpen: function (open) {

                        },
                    });
                }
            })
            FastClick.attach(document.body);
            $("input[name='isTeam']").change(function () {
                var isTeam = $("input[name='isTeam']:checked").val();
                if (0 == isTeam) {
                    $(".team_show").hide()
                } else {
                    $(".team_show").show()
                }
            })
            var online = $("input[name='online']:checked").val();
            if (1 == online) {
                $(".reference_show").hide()
                $(".document_show").hide()
                $(".emergency_show").hide()
                $(".wx_number_show").hide()
                // $(".pca_show").hide()

            } else {
                $(".reference_show").show()
                $(".document_show").show()
                $(".emergency_show").show()
                $(".wx_number_show").show()
                // $(".pca_show").show()
            }
            $("input[name='online']").change(function () {

                var online = $("input[name='online']:checked").val();

                if (1 == online) {
                    $(".reference_show").hide()
                    $(".document_show").hide()
                    $(".emergency_show").hide()
                    $(".wx_number_show").hide()
                    // $(".pca_show").hide()
                } else {

                    $(".reference_show").show()
                    $(".document_show").show()
                    $(".emergency_show").show()
                    $(".wx_number_show").show()
                    // $(".pca_show").show()
                }
            })
        }


    </script>
</head>
<body ontouchstart>
<form accept-charset="UTF-8" action="" id="basic_form" method="get" name="basic_form">
    <img style="width: 100%;" src="${pic}">
    <header class='demos-header'>
        <h2 class="demos-second-title">${eventName}</h2>
    <#--<h2 class="demos-second-title">赛事报名</h2>-->
    </header>

    <div class="participantCode_show" style="display: none;">
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">参赛号码</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="text" readonly id="participantCode" name="participantCode"/>
            </div>
        </div>
    </div>

    <input type="hidden" id="eventId" readonly name="eventId" class="eventId" value="${eventId}"/>
    <div class="weui-cells__title">赛事组别</div>
    <div class="weui-cells weui-cells_checkbox" id="group_content">

    </div>
    <div class="online_show">
        <div class="weui-cells__title">参赛方式</div>
        <div class="weui-cells weui-cells_checkbox">
            <label class="weui-cell weui-check__label" for="x1">
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" name="online" id="x1" value="1">
                    <span class="weui-icon-checked"></span>
                </div>
                <div class="weui-cell__bd">
                    <p>线上</p>
                </div>

            </label>
            <label class="weui-cell weui-check__label" for="x2">
                <div class="weui-cell__ft">
                    <input type="radio" name="online" class="weui-check" id="x2" value="0" checked="checked">
                    <span class="weui-icon-checked"></span>
                </div>
                <div class="weui-cell__bd">
                    <p>线下</p>
                </div>

            </label>
        </div>
    </div>

    <div class="teamId_show">
        <div class="weui-cells__title">个人/团队</div>
        <div class="weui-cells weui-cells_checkbox">
            <label class="weui-cell weui-check__label" for="x14">
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" name="isTeam" id="x14" value="0">
                    <span class="weui-icon-checked"></span>
                </div>
                <div class="weui-cell__bd">
                    <p>个人赛</p>
                </div>

            </label>
            <label class="weui-cell weui-check__label" for="x15">
                <div class="weui-cell__ft">
                    <input type="radio" name="isTeam" class="weui-check" id="x15" value="1" checked="checked">
                    <span class="weui-icon-checked"></span>
                </div>
                <div class="weui-cell__bd">
                    <p>团队赛</p>
                </div>

            </label>
        </div>


        <div class="weui-cells__title">团队</div>

        <div class="weui-cell">
            <div class="weui-cell__hd"><label for="team_id" class="weui-label">所属团队<span
                    style="color: red"> * </span></label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="text" value="" readonly="" placeholder="请选择" id="team_id"
                       name="team_id">
            </div>
        </div>
        <a href="javascript:void(0);" id="creata_team" class="weui-cell weui-cell_link">
            <div class="weui-cell__bd">没有团队？添加</div>
        </a>
    </div>
    <div class="alumni_id_show">
        <div class="weui-cells__title">校友会</div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label for="alumni_id" class="weui-label">所属校友会<span
                    style="color: red"> * </span></label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="text" value="" readonly="" placeholder="请选择" id="alumni_id"
                       name="alumni_id">
            </div>
        </div>
    </div>
    <div class="alumni_relation_persion_show">
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">校友会联系人<span style="color: red"> * </span></label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="text" placeholder="校友会联系人" id="alumni_relation_persion"
                       name="alumni_relation_persion"
                       maxlength="100"/>
            </div>
        </div>
    </div>
    <div class="roleId_show">
        <div class="weui-cell">
            <div class="weui-cell__hd"><label for="role_id" class="weui-label">角色<span
                    style="color: red"> * </span></label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="text" value="" readonly="" placeholder="请选择" id="role_id"
                       name="role_id">
            </div>
        </div>
    </div>
    <div class="event_price_show">
        <div class="weui-cells__title">保险</div>
        <div class="weui-cells weui-cells_form">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="event_price_id" class="weui-label">选择套餐<span
                        style="color: red"> * </span></label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" value="" readonly="" placeholder="请选择" id="event_price_id"
                           name="event_price_id">
                </div>
            </div>
        </div>
    </div>

    <div class="weui-cells__title">基本信息填写</div>
    <div class="weui-cells weui-cells_form">
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">姓名<span style="color: red"> * </span></label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="text" placeholder="请输入姓名" id="name" name="name" maxlength="100"/>
            </div>

        </div>

        <div class="weui-cell">
            <div class="weui-cell__hd"><label for="gender" class="weui-label">性别<span
                    style="color: red"> * </span></label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="text" value="" readonly="" placeholder="请选择" id="gender" name="gender">
            </div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__hd"><label for="personal_mobile" class="weui-label">手机号<span
                    style="color: red"> * </span></label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="number" placeholder="请输入手机号" id="personal_mobile"
                       name="personal_mobile" maxlength="100"/>
            </div>
        </div>

        <div class="document_show">
            <div class="weui-cell" style="border-top: 1px solid rgba(0,0,0,0.05);">
                <div class="weui-cell__hd"><label for="wx_number" class="weui-label">微信号<span
                        style="color: red"> * </span></label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" placeholder="请输入微信号" id="wx_number" maxlength="100"
                           name="wx_number"/>
                </div>
            </div>

            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="document_type" class="weui-label">证件类型<span
                        style="color: red"> * </span></label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" value="" readonly="" placeholder="请选择" id="document_type"
                           name="document_type">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">证件号码<span style="color: red"> * </span></label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" placeholder="用于保险购买" id="document_num" maxlength="100"
                           name="document_num"/>
                </div>
            </div>
        </div>
        <div class="nationality_show">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">国籍<span style="color: red"> * </span></label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" placeholder="请输入国籍" id="nationality" maxlength="100"
                           name="nationality"/>
                </div>
            </div>
        </div>
        <div class="nation_show">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">民族<span style="color: red"> * </span></label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" placeholder="请输入民族" id="nation" maxlength="100"
                           name="nation"/>
                </div>
            </div>
        </div>

        <div class="birthday_show">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="birthday" class="weui-label">生日<span
                        style="color: red"> * </span></label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" value="" placeholder="请选择" id="birthday" name="birthday">
                </div>
            </div>
        </div>
        <div class="bloodType_show">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="blood_type" class="weui-label">血型<span
                        style="color: red"> * </span></label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" value="" readonly="" placeholder="请选择" id="blood_type"
                           name="blood_type">
                </div>
            </div>
        </div>
        <div class="clothingSize_show">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="clothing_size" class="weui-label">衣服尺寸<span
                        style="color: red"> * </span></label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" value="" readonly="" placeholder="请选择" id="clothing_size"
                           name="clothing_size">
                </div>
            </div>
        </div>
        <div class="education_show">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="education" class="weui-label">学历<span
                        style="color: red"> * </span></label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" value="" readonly="" placeholder="请选择" id="education"
                           name="education">
                </div>
            </div>
        </div>
        <div class="country_show">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="country" class="weui-label">国家<span style="color: red"> * </span></label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" placeholder="请输入国家" id="country" maxlength="100"
                           name="country"/>
                </div>
            </div>
        </div>
        <#--<div class="pca_show">-->
            <#--<div class="weui-cell">-->
                <#--<div class="weui-cell__hd"><label for="pca" class="weui-label">省市县<span-->
                        <#--style="color: red"> * </span></label></div>-->
                <#--<div class="weui-cell__bd">-->
                    <#--<input class="weui-input" id="pca" type="text" value="" placeholder="请选择省市县" name="pca">-->
                <#--</div>-->
            <#--</div>-->
            <#--<div class="weui-cell">-->
                <#--<div class="weui-cell__hd"><label for="addr" class="weui-label">地址<span-->
                        <#--style="color: red"> * </span></label></div>-->
                <#--<div class="weui-cell__bd">-->
                    <#--<input class="weui-input" type="text" placeholder="请输入地址" id="addr" maxlength="200" name="addr"/>-->
                <#--</div>-->
            <#--</div>-->
        <#--</div>-->
        <div class="email_show">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="email" class="weui-label">邮箱<span
                        style="color: red"> * </span></label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" placeholder="请输入邮箱" id="email" maxlength="100" name="email"/>
                </div>
            </div>
        </div>
        <div class="document_show">
            <div class="weui-cell">
                <div class="weui-cell__bd">
                    <p style="color: red;font-size: 12px">本次邀请赛 线下活动为1对1邀请，请认真填写邀请人，如邀请人无效则审核不通过</p>
                </div>
            </div>
        </div>
        <div class="weui-cells__title">基本信息补充</div>
        <div class="occupation_show">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="occupation" class="weui-label">职业<span
                        style="color: red"> * </span></label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" placeholder="请输入职业" id="occupation" maxlength="100"
                           name="occupation"/>
                </div>
            </div>
        </div>
        <div class="company_name_show">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="company_name" class="weui-label">公司名称<span
                        style="color: red"> * </span></label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" placeholder="请输入公司名称" id="company_name" maxlength="100"
                           name="company_name"/>
                </div>
            </div>
        </div>
        <div class="company_position_show">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="company_position" class="weui-label">公司职务<span
                        style="color: red"> * </span></label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" placeholder="请输入公司职务" id="company_position" maxlength="100"
                           name="company_position"/>
                </div>
            </div>
        </div>
        <div class="passedPhysicalExam_show">
            <div class="weui-cell weui-cell_switch">
                <div class="weui-cell__bd">是否通过体检</div>
                <div class="weui-cell__ft">
                    <label for="passed_physical_exam" class="weui-switch-cp">
                        <input id="passed_physical_exam" name="passed_physical_exam" class="weui-switch-cp__input"
                               type="checkbox" checked="checked">
                        <div class="weui-switch-cp__box"></div>
                    </label>
                </div>
            </div>
        </div>
        <div class="trainingMileage_show">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="training_mileage" class="weui-label">训练里程<span
                        style="color: red"> * </span></label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="number" placeholder="(公里)" id="training_mileage"
                           name="training_mileage"
                           maxlength="100"/>
                </div>
            </div>
        </div>

        <div class="document_show">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="reference" class="weui-label">邀请人<span
                        style="color: red"> * </span></label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" placeholder="请输入邀请人" id="reference" maxlength="100"
                           name="reference"/>
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="emergency_contact_name" class="weui-label">紧急联系人<span
                        style="color: red"> * </span></label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" placeholder="请输入紧急联系人" id="emergency_contact_name"
                           name="emergency_contact_name"
                           maxlength="100"/>
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="emergency_contact_mobile" class="weui-label">紧急人电话<span
                        style="color: red"> * </span></label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="number" placeholder="请输入紧急人联系电话" id="emergency_contact_mobile"
                           name="emergency_contact_mobile"
                           maxlength="100"/>
                </div>
            </div>
        </div>
        <div class="events_in_recent_year_show">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="events_in_recent_year" class="weui-label">参加的赛事<span
                        style="color: red"> * </span></label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" placeholder="最近一年参加过的赛事" id="events_in_recent_year"
                           name="events_in_recent_year"
                           maxlength="100"/>
                </div>
            </div>
        </div>
        <div class="best_result_show">
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label for="best_result" class="weui-label">最好成绩<span style="color: red"> * </span></label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" placeholder="请输入最好成绩" id="best_result" name="best_result"
                           maxlength="100"/>
                </div>
            </div>
        </div>
    <#--<div class="reference_show">-->

        <div class="weui-cell">
            <div class="weui-cell__hd"><label for="run_team_name" class="weui-label">跑团名(选填)</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="text" placeholder="请输入跑团名" id="run_team_name" maxlength="100"
                       name="run_team_name"/>
            </div>
        </div>

    <#--</div>-->
    <#--<div class="file_show">-->
        <div class="weui-cell">
            <div class="weui-cell__bd">
                <div class="weui-uploader">
                    <div class="weui-uploader__hd">
                        <p class="weui-uploader__title">完赛证书上传:<span style="color: red"> * </span></p>
                        <div class="weui-uploader__info"><span id="uploadCount">0</span>/4</div>
                    </div>


                    <div class="weui-uploader__bd">
                        <ul class="weui-uploader__files" id="uploaderFiles">
                        </ul>
                        <div class="weui-uploader__input-box">
                            <input id="uploaderInput" class="weui-uploader__input" type="file"
                                   accept="image/jpg,image/jpeg,image/png,image/gif" multiple="">
                        </div>
                    </div>
                    <p style="color: red;font-size: 12px">完赛证书或7月份总跑量截图上传</p>
                </div>
            </div>
        </div>
    <#--</div>-->

        <div class="weui-gallery" id="gallery">
            <span class="weui-gallery__img" id="galleryImg"></span>
            <div class="weui-gallery__opr">
                <a href="javascript:" class="weui-gallery__del">
                    <i class="weui-icon-delete weui-icon_gallery-delete"></i>
                </a>
            </div>
        </div>
        <div class="weui-btn-area">
            <a class="weui-btn weui-btn_primary" href="javascript:" id="next">下一步</a>
        </div>
        <div class="weui-article section"></div>

</form>
</body>


<div class="add_team_show">
    <div id="mask">
        <style>
            #mask {
                position: fixed;
                background: rgba(0, 0, 0, .3);
                display: none;
                width: 100%;
                height: 100%;
                top: 0;
                z-index: 3;
            }

            #bgDiv {
                position: absolute;
                top: 33.3%;
                width: 100%;
                background-color: white;
                z-index: 4;
            }

            #add_team_close {
                position: absolute;
                top: 6px;
                right: 12px;
            }
        </style>

        <div id="bgDiv">
            <div class="weui-cells__title">创建团队</div>
            <span id="add_team_close">x</span>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="teamname" class="weui-label"><span style="color: red"> * </span>团队名称</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" value="" placeholder="请输入" id="teamname">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="teamcode" class="weui-label"><span style="color: red"> * </span>团队代码</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" value="" placeholder="请输入" id="teamcode">
                </div>
            </div>
            <div class="weui-btn-area">
                <a class="weui-btn weui-btn_primary" href="javascript:" id="add_team_next">添加</a>

            </div>
        </div>
    </div>

    <script>

        $("#creata_team").click(function () {
            $(".add_team_show").show();
            $("mask").show();
        })
        $("#add_team_close").click(function () {
            $(".add_team_show").hide();
            $("#mask").hide();
            $("#teamname").val('');
            $("#teamcode").val('');
        })

        $("#add_team_next").click(function () {
            if ('' === $("#teamname").val()) {
                $.toptip('警告,团队名称不能为空', 'warning');
                return false;
            }
            if ('' === $("#teamcode").val()) {
                $.toptip('警告,团队代码不能为空', 'warning');
                return false;
            }
            var teamAddParam = {}
            teamAddParam.id = 0;
            teamAddParam.name = $("#teamname").val();
            teamAddParam.code = $("#teamcode").val();
            teamAddParam.eventId = ${eventId}
                    $.ajax({
                        url: "/participant/team/add",
                        method: "post",
                        dataType: "json",

                        contentType: "application/json",
                        data: JSON.stringify(teamAddParam),
                        success: function (res) {
                            console.log(res)
                            if (res.status === 1) {
                                $.toptip('成功', 'success');
                                $(".add_team_show").hide();
                                $.ajax({
                                    url: "/participant/team/list/by/eventId?eventId=" +${eventId},
                                    method: "post",
                                    dataType: "json",

                                    contentType: "application/json",
                                    success: function (res) {
                                        let teams = [] = res.data;

                                        let items = []
                                        if (teams.length !== 0) {

                                            for (let i = 0; i < teams.length; i++) {
                                                let item = {}
                                                item.title = teams[i].name
                                                item.value = teams[i].id
                                                items.push(item)
                                            }
                                        }
                                        $("#team_id").select("update", {
                                            title: "选择团队",
                                            items: items,
                                            onChange: function (d) {
                                            },
                                            onClose: function () {
                                            },
                                            onOpen: function () {
                                            },
                                        });
                                    }
                                });
                            } else {
                                var msg = res.msg;
                                $.toptip(msg + '', 'warning');
                            }
                        }
                    })
        })
    </script>
</div>


<script>

    var province = "黑龙江省";
    var city = "哈尔滨市";
    var area = "道里区";
    $("#document_type").val("身份证")
    $("#document_type").attr("data-values", 1)
    $("#gender").val("男")
    $("#gender").attr("data-values", "1")
    // $("#pca").val("黑龙江省 哈尔滨市 道里区")

    // $("#pca").cityPicker({
    //     title: "选择省市县",
    //     onChange: function (picker, values, displayValues) {
    //         province = displayValues[0];
    //         city = displayValues[1];
    //         area = displayValues[2];
    //     }
    // });
    $("#gender").select({
        title: "选择性别",
        items: [{
            title: "男",
            value: "1"
        },
            {
                title: "女",
                value: "0"
            }
        ],
        onChange: function (d) {
        },
        onClose: function () {
        },
        onOpen: function () {
        },
    });

    $("#document_type").select({
        title: "选择证件类型",
        items: [{
            title: "身份证",
            value: "1"
        },
            {
                title: "港澳台通行证",
                value: "2"
            },
            {
                title: "护照",
                value: "3"
            },
        ],
        onChange: function (d) {
        },
        onClose: function () {
        },
        onOpen: function () {
        },
    });

    $("#blood_type").select({
        title: "选择血型",
        items: ["A", "B", "AB", "O"],
        onChange: function (d) {
        },
        onClose: function () {
        },
        onOpen: function () {
        },
    });
    $("#education").select({
        title: "选择学历",
        items: ["中专", "大专", "本科", "硕士", "博士", "博士后"],
        onChange: function (d) {
        },
        onClose: function () {
        },
        onOpen: function () {
        },
    });
    $("#clothing_size").select({
        title: "选择衣服尺寸",
        items: ["XS", "S", "M", "L", "XL", "XXL", "XXXL", "XXXXL"],
        onChange: function (d) {
        },
        onClose: function () {
        },
        onOpen: function () {
        },
    });
    var today = new Date();
    today.setTime(today.getTime());
    var todayStr = today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDate();


    $("#birthday").calendar({
        value: [todayStr],
        dateFormat: 'yyyy年mm月dd日' // 自定义格式的时候，不能通过 input 的value属性赋值 '2016年12月12日' 来定义初始值，这样会导致无法解析初始值而报错。只能通过js中设置 value 的形式来赋值，并且需要按标准形式赋值（yyyy-mm-dd 或者时间戳)
    });

    $("#years-monthes").datetimePicker({
        title: '限定年月',
        years: [2020, 2021],
        monthes: ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'],
        onChange: function (picker, values, displayValues) {
        }
    });

    function getOS() {
        var sUserAgent = navigator.userAgent;
        var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
        var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform ==
                "Macintosh") || (navigator.platform == "MacIntel");
        if (isMac) return "Mac";
        var isUnix = (navigator.platform == "X11") && !isWin && !isMac;
        if (isUnix) return "Unix";
        var isLinux = (String(navigator.platform).indexOf("Linux") > -1);
        if (isLinux) return "Linux";
        if (isWin) {
            var isWin2K = sUserAgent.indexOf("Windows NT 5.0") > -1 || sUserAgent.indexOf("Windows 2000") > -1;
            if (isWin2K) return "Win2000";
            var isWinXP = sUserAgent.indexOf("Windows NT 5.1") > -1 || sUserAgent.indexOf("Windows XP") > -1;
            if (isWinXP) return "WinXP";
            var isWin2003 = sUserAgent.indexOf("Windows NT 5.2") > -1 || sUserAgent.indexOf("Windows 2003") > -1;
            if (isWin2003) return "Win2003";
            var isWinVista = sUserAgent.indexOf("Windows NT 6.0") > -1 || sUserAgent.indexOf("Windows Vista") > -1;
            if (isWinVista) return "WinVista";
            var isWin7 = sUserAgent.indexOf("Windows NT 6.1") > -1 || sUserAgent.indexOf("Windows 7") > -1;
            if (isWin7) return "Win7";
            var isWin10 = sUserAgent.indexOf("Windows NT 10") > -1 || sUserAgent.indexOf("Windows 10") > -1;
            if (isWin10) return "Win10";
        }
        return "other";
    }

    var browserInfo = {};
    var explorer = window.navigator.userAgent.toLowerCase();
    //ie
    if (explorer.indexOf("msie") >= 0) {
        var ver = explorer.match(/msie ([\d.]+)/)[1];
        browserInfo = {
            type: "IE",
            version: ver
        };
    }
    //firefox
    else if (explorer.indexOf("firefox") >= 0) {
        var ver = explorer.match(/firefox\/([\d.]+)/)[1];
        browserInfo = {
            type: "Firefox",
            version: ver
        };
    }
    //Chrome
    else if (explorer.indexOf("chrome") >= 0) {
        var ver = explorer.match(/chrome\/([\d.]+)/)[1];
        browserInfo = {
            type: "Chrome",
            version: ver
        };
    }
    //Opera
    else if (explorer.indexOf("opera") >= 0) {
        var ver = explorer.match(/opera.([\d.]+)/)[1];
        browserInfo = {
            type: "Opera",
            version: ver
        };
    }
    //Safari
    else if (explorer.indexOf("safari") >= 0) {
        var ver = explorer.match(/version\/([\d.]+)/);
        if (ver != null) {
            browserInfo = {
                type: "Safari",
                version: ver[1]
            };
        } else {
            browserInfo = {
                type: "Safari",
                version: 11.0
            };
        }

    }


    getDevice = () => {
        let agent = navigator.userAgent.toLowerCase();
        let result = {
            device: function () {
                if (/windows/.test(agent)) {
                    return 'windows pc';
                } else if (/iphone|ipod/.test(agent) && /mobile/.test(agent)) {
                    return 'iphone';
                } else if (/ipad/.test(agent) && /mobile/.test(agent)) {
                    return 'ipad';
                } else if (/android/.test(agent) && /mobile/.test(agent)) {
                    return 'android';
                } else if (/linux/.test(agent)) {
                    return 'linux pc';
                } else if (/mac/.test(agent)) {
                    return 'mac';
                } else {
                    return 'other';
                }
            }(),
        };
        return result;
    };


    var param = {
        "addr": "",
        "alumniId": "",
        "alumniRelationPersion": "",
        "amount": "",
        "area": "",
        "bestResult": "",
        "birthday": "",
        "bloodType": "",
        "browser": "",
        "city": "",
        "clothingSize": "",
        "companyName": "",
        "companyPosition": "",
        "country": "",
        "documentNum": "",
        "documentType": "",
        "education": "",
        "email": "",
        "emergencyContactMobile": "",
        "emergencyContactName": "",
        "equipment": "",
        "eventId": "",
        "eventPriceId": "",
        "eventsInRecentYear": "",
        "groupId": "",
        "infoId": "",
        "ip": returnCitySN["cip"],
        "name": "",
        "nation": "",
        "nationality": "",
        "occupation": "",
        "os": getOS(),
        "openId": "",
        "passedPhysicalExam": "",
        "personalMobile": "",
        "pic": "",
        "province": "",
        "raceId": "",
        "roleId": "",
        "sex": "",
        "teamId": "",
        "online": "",
        "trainingMileage": "",
        "eventsInRecentYear": "",
        "bestResult": "",
        "reference": "",
        "runTeamName": "",
        "wxNumber": ""
    }

    var bitrhday_str = ""
    $("#document_type").change(function () {
        let typed = ($("#document_type").attr("data-values"))
        if (typed == 1) {
            var str = $("#document_num").val()
            if (str.length == 18) {
                var birstr = str.substring(6, 14);
                var yearstr = birstr.substring(0, 4)
                var montr = birstr.substring(4, 6)
                var daystr = birstr.substring(6, 9)
                bitrhday_str = yearstr + "年" + montr + "月" + daystr + "日"
                $("#birthday").val(bitrhday_str)
                var genderstr = str.substring(16, 17);
                var genderCode = (parseInt(genderstr) % 2 == 0) ? "0" : "1"
                var genderName = (parseInt(genderstr) % 2 == 0) ? "女" : "男"
                $("#gender").attr("data-values", genderCode)
                $("#gender").val(genderName)
            }
        }
    })


    $("#document_num").change(function () {
        let typed = ($("#document_type").attr("data-values"))
        if (typed == undefined || typed == "") {
            $.toptip('警告,证件类型不能为空', 'warning');
            return false;
        }
        if (typed == 1) {
            var str = $("#document_num").val()
            if (str.length == 18) {
                var birstr = str.substring(6, 14);
                var yearstr = birstr.substring(0, 4)
                var montr = birstr.substring(4, 6)
                var daystr = birstr.substring(6, 9)
                bitrhday_str = yearstr + "年" + montr + "月" + daystr + "日"
                $("#birthday").val(bitrhday_str)
                var genderstr = str.substring(16, 17);
                var genderCode = (parseInt(genderstr) % 2 == 0) ? "0" : "1"
                var genderName = (parseInt(genderstr) % 2 == 0) ? "女" : "男"
                $("#gender").attr("data-values", genderCode)
                $("#gender").val(genderName)
            }
        }
    })

    $("#next").click(function () {

        $.showLoading("数据提交中");

        var group_id = parseInt($("input[name='group_id']:checked").val());
        var eventId = $("#eventId").val();

        // param.addr = $("#addr").val();
        param.alumniId = parseInt($("#alumni_id").attr("data-values"));
        param.alumniRelationPersion = $("#alumni_relation_persion").val();
        param.amount = $("#amount").val() == undefined ? "" : $("#amount").val();


        param.bestResult = $("#best_result").val();
        param.birthday = $("#birthday").val();
        param.bloodType = $("#blood_type").val();

        param.clothingSize = $("#clothing_size").val();
        param.companyName = $("#company_name").val();
        param.companyPosition = $("#company_position").val();

        param.country = $("#country").val();

        param.documentNum = $("#document_num").val();
        param.documentType = $("#document_type").attr("data-values");

        param.education = $("#education").val();
        param.email = $("#email").val();
        param.emergencyContactMobile = $("#emergency_contact_mobile").val();
        param.emergencyContactName = $("#emergency_contact_name").val();
        param.equipment = getDevice().device;
        param.eventId = parseInt(eventId);
        param.eventPriceId = parseInt($("#event_price_id").attr("data-values"));
        param.eventsInRecentYear = $("#events_in_recent_year").val();

        param.groupId = group_id == undefined ? "" : parseInt(group_id);

        param.infoId = $("#info_id").val() == undefined ? "" : parseInt($("#info_id").val());

        param.name = $("#name").val();
        param.nation = $("#nation").val();
        param.nationality = $("#nationality").val();
        param.occupation = $("#occupation").val();
        param.openId = window.localStorage.getItem("openid");
        param.passedPhysicalExam = $("#passed_physical_exam").is(":checked") == true ? 1 : 0
        param.personalMobile = $("#personal_mobile").val();


        param.raceId = $("#race_id").val() == undefined ? "" : parseInt($("#race_id").val());

        param.roleId = parseInt($("#role_id").attr("data-values"));
        param.sex = parseInt($("#gender").attr("data-values"));

        param.reference = $("#reference").val();
        param.runTeamName = $("#run_team_name").val();
        param.wxNumber = $("#wx_number").val();
        var isTeam = $("input[name='isTeam']:checked").val();
        if (isTeam == 1) {
            param.teamId = parseInt($("#team_id").attr("data-values"));
        } else {
            param.teamId = "";
        }

        param.online = $("input[name='online']:checked").val();

        if (param.online == 0) {
            param.province = province;
            param.city = city;
            param.area = area;
        }

        param.trainingMileage = $("#training_mileage").val();

        if (validate(param)) {

            param.pic = "";
            var count = 0;
            for (var i = picList.length - 1; i >= 0; i--) {
                var content = picList[i];
                $.ajax({
                    url: "/putDataBase64Jpg",
                    method: "post",
                    dataType: "json",
                    async: false,
                    contentType: "application/json",
                    data: JSON.stringify({"content": content}),
                    success: function (res) {
                        param.pic = param.pic + res.data + ',';
                        count++;
                    }
                })
            }
            if (pageParam.pic) {
                if (param.pic == "") {
                    $.toptip('警告,完赛证书截图不能为空', 'warning');
                    $.hideLoading();
                    return false;
                }
            }
            if (count == picList.length) {
                $("#next").hide();
                $.ajax({
                    url: "/participant/sign/up",
                    method: "post",
                    dataType: "json",
                    async: false,
                    contentType: "application/json",
                    data: JSON.stringify(param),
                    success: function (res) {
                        console.log(res)
                        if (res.status === 1) {
                            $.hideLoading();

                            if (price == 0) {
                                $.ajax({
                                    url: "/participant/pay/zero",
                                    method: "post",
                                    dataType: "json",
                                    async: false,
                                    contentType: "application/json",
                                    data: JSON.stringify({
                                        "pib": res.data.pibId,
                                        "eventPriceId": res.data.eventPriceId,
                                        "tradeType": 1,
                                        "openId": openId
                                    }),
                                    success: function (res) {
                                        console.log(res);
                                        let param = res.data;
                                        if (res.status === 1) {
                                            window.location.href = "/event${eventId}/success.html"
                                        }
                                        else {
                                            window.location.href = "/event${eventId}/failed.html"
                                        }
                                    }
                                })
                            } else {
                                $.toptip('报名成功，准备跳转支付页', 'success');
                                window.location.href =
                                        "/event${eventId}/part2.html" +
                                        "?raceId=" + res.data.raceId +
                                        "&isTeam=" + isTeam
                            }
                        } else {
                            $.hideLoading();
                            var msg = res.msg;
                            $.toptip(msg + '', 'warning');

                        }
                    }
                })
            } else {
                $.hideLoading();
                return false;
            }
        } else {
            $.hideLoading();
            return false;
        }
        $.hideLoading();
    })


    /**
     * 验证是否为手机号码（移动手机）
     *
     * @param {}
     *            source
     */
    function isMobilePhone(source) {
        var regex = /^[1]([3-9])[0-9]{9}$/;
        return regex.test(source);
    }

    /**
     验证身份证号是否正确
     **/

    function IdentityCodeValid(code) {
        var city = {
            11: "北京",
            12: "天津",
            13: "河北",
            14: "山西",
            15: "内蒙古",
            21: "辽宁",
            22: "吉林",
            23: "黑龙江 ",
            31: "上海",
            32: "江苏",
            33: "浙江",
            34: "安徽",
            35: "福建",
            36: "江西",
            37: "山东",
            41: "河南",
            42: "湖北 ",
            43: "湖南",
            44: "广东",
            45: "广西",
            46: "海南",
            50: "重庆",
            51: "四川",
            52: "贵州",
            53: "云南",
            54: "西藏 ",
            61: "陕西",
            62: "甘肃",
            63: "青海",
            64: "宁夏",
            65: "新疆",
            71: "台湾",
            81: "香港",
            82: "澳门",
            91: "国外 "
        };
        var tip = "";
        var pass = true;

        if (!code || !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(code)) {
            tip = "身份证号格式错误";
            pass = false;
        } else if (!city[code.substr(0, 2)]) {
            tip = "地址编码错误";
            pass = false;
        } else {
            //18位身份证需要验证最后一位校验位
            if (code.length == 18) {
                code = code.split('');
                //∑(ai×Wi)(mod 11)
                //加权因子
                var factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
                //校验位
                var parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2];
                var sum = 0;
                var ai = 0;
                var wi = 0;
                for (var i = 0; i < 17; i++) {
                    ai = code[i];
                    wi = factor[i];
                    sum += ai * wi;
                }
                var last = parity[sum % 11];
                if (parity[sum % 11] != code[17]) {
                    tip = "请输入正确的身份证号";
                    pass = false;
                }
            }
        }
        if (!pass) $.toptip('警告,' + tip, 'warning');
        return pass;
    }


    function validate(param) {
        console.log(param)
        //验证邮箱
        var emailReg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;


        if (isNaN(param.eventPriceId)) {
            $.toptip('警告,套餐不能为空', 'warning');
            return false;
        }
        if (param.name == "") {
            $.toptip('警告,姓名不能为空', 'warning');
            return false;
        }

        if (isNaN(param.sex)) {
            $.toptip('警告,性别不能为空', 'warning');
            return false;
        }


        if (param.personalMobile == "") {
            $.toptip('警告,手机号不能为空', 'warning');
            return false;
        }
        if (!isMobilePhone(param.personalMobile)) {
            $.toptip('警告,手机号输入错误', 'warning');
            return false;
        }

        if (param.online == 0) {
            if (param.wxNumber == "") {
                $.toptip('警告,微信号不能为空', 'warning');
                return false;
            }
            if (isNaN(param.documentType)) {
                $.toptip('警告,证件类型不能为空', 'warning');
                return false;
            }

            if ("1" === (param.documentType)) {
                if (!IdentityCodeValid(param.documentNum)) {
                    $.toptip('警告,证件号码格式不对', 'warning');
                    return false;
                }
            }
            if (param.province == "") {
                $.toptip('警告,省不能为空', 'warning');
                return false;
            }
            if (param.city == "") {
                $.toptip('警告,城市不能为空', 'warning');
                return false;
            }
            if (param.area == "") {
                $.toptip('警告,地区不能为空', 'warning');
                return false;
            }
            // if (param.addr == "") {
            //     $.toptip('警告,地址不能为空', 'warning');
            //     return false;
            // }
            if (param.reference == "") {
                $.toptip('警告,邀请人不能为空', 'warning');
                return false;
            }
            if (param.emergencyContactName == "") {
                $.toptip('警告,紧急联系人不能为空', 'warning');
                return false;
            }
            if (param.emergencyContactMobile == "") {
                $.toptip('警告,紧急联系人电话不能为空', 'warning');
                return false;
            }

            if (!isMobilePhone(param.emergencyContactMobile)) {
                $.toptip('警告,紧急联系人电话输入错误', 'warning');
                return false;
            }


        }
        if (price !== 0 || param.online == 0) {
            if (isNaN(param.documentType)) {
                $.toptip('警告,证件类型不能为空', 'warning');
                return false;
            }

            if ("1" === (param.documentType)) {
                if (!IdentityCodeValid(param.documentNum)) {
                    $.toptip('警告,证件号码格式不对', 'warning');
                    return false;
                }
            }
        }

        if (pageParam.email) {
            if (param.email == "") {
                $.toptip('警告,邮箱不能为空', 'warning');
                return false;
            }
        }
        if (pageParam.occupation) {
            if (param.occupation == "") {
                $.toptip('警告,职业不能为空', 'warning');
                return false;
            }
        }
        if (pageParam.education) {
            if (param.education == "") {
                $.toptip('警告,学历不能为空', 'warning');
                return false;
            }
        }

        if (pageParam.companyName) {
            if (param.companyName == "") {
                $.toptip('警告,公司名不能为空', 'warning');
                return false;
            }
        }
        if (pageParam.companyPosition) {
            if (param.companyPosition == "") {
                $.toptip('警告,公司职务不能为空', 'warning');
                return false;
            }
        }
        if (pageParam.eventsInRecentYear) {
            if (param.eventsInRecentYear == "") {
                $.toptip('警告,最近赛事不能为空', 'warning');
                return false;
            }
        }
        if (pageParam.bestResult) {
            if (param.bestResult == "") {
                $.toptip('警告,最好成绩不能为空', 'warning');
                return false;
            }
        }

        if (pageParam.alumniRelationPersion) {
            if (param.alumniRelationPersion == "") {
                $.toptip('警告,校友会联系人不能为空', 'warning');
                return false;
            }
        }
        if (pageParam.alumniId) {
            if (param.alumniId == "") {
                $.toptip('警告,校友会不能为空', 'warning');
                return false;
            }
        }
        if (pageParam.teamId) {
            var isTeam = $("input[name='isTeam']:checked").val();
            if (isTeam == 1) {

                if (isNaN(param.teamId)) {
                    $.toptip('警告,团队不能为空', 'warning');
                    return false;
                }
            }
        }

        if (pageParam.roleId) {
            if (isNaN(param.roleId)) {
                $.toptip('警告,角色不能为空', 'warning');
                return false;
            }
        }
        if (pageParam.nationality) {
            if (param.nationality == "") {
                $.toptip('警告,国籍不能为空', 'warning');
                return false;
            }
        }
        if (pageParam.nation) {
            if (param.nation == "") {
                $.toptip('警告,民族不能为空', 'warning');
                return false;
            }
        }
        if (pageParam.birthday) {
            if (param.birthday == "") {
                $.toptip('警告,生日不能为空', 'warning');
                return false;
            }
        }
        if (pageParam.bloodType) {
            if (param.bloodType == "") {
                $.toptip('警告,血型不能为空', 'warning');
                return false;
            }
        }
        if (pageParam.clothingSize) {
            if (param.clothingSize == "") {
                $.toptip('警告,衣服尺寸不能为空', 'warning');
                return false;
            }
        }
        if (pageParam.country) {
            if (param.country == "") {
                $.toptip('警告,国家不能为空', 'warning');
                return false;
            }
        }
        if (pageParam.trainingMileage) {
            if (param.trainingMileage == "") {
                $.toptip('警告,训练里程不能为空', 'warning');
                return false;
            }
        }

        return true;
    }

    // 允许上传的图片类型
    var allowTypes = ['image/jpg', 'image/jpeg', 'image/png', 'image/gif'];
    var maxSize = 1024 * 1024 * 5; // 10240KB，也就是 10MB
    var maxWidth = 1900;  // 图片最大宽度
    var maxCount = 4;// 最大上传图片数量

    //
    var tmpl = '<li class="weui-uploader__file" id="#ImgID#" style="background-image:url(#url#)"><div class="weui_uploader_status_content" style="color:red">0%</div></li>',
            $gallery = $("#gallery"),
            $galleryImg = $("#galleryImg"),
            $uploaderInput = $("#uploaderInput"),
            $uploaderFiles = $("#uploaderFiles");

    // //回显

    setTimeout(function () {
        openId = window.localStorage.getItem("openid");
        $.ajax({
            url: "/participant/all/data/by/openId/eventId?eventId=${eventId}&openId=" + openId,
            method: "post",
            dataType: "json",
            async: false,
            contentType: "application/json",
            success: function (res) {
                var partData = (res.data);
                if (partData != null && partData != undefined) {
                    if (partData.status != 0
                            && partData.status != -1
                            && partData.status != -2
                            && partData.status != -3) {
                        $("#next").hide()
                        $(".participantCode_show").show()

                        if (partData.participantCode != null) {
                            $("#participantCode").val(partData.participantCode);
                        }

                        if (partData.pic != null) {
                            let picList = partData.pic.split(',');
                            for (let i = 0; i < picList.length; i++) {
                                $uploaderFiles.append($(tmpl.replace('#url#', picList[i]).replace('#ImgID#', genGUID())))
                            }
                            $uploaderFiles.find('.weui_uploader_status_content').text('');
                            var num = $('.weui-uploader__file').length;
                            $('#uploadCount').text(num);
                            param.pic = partData.pic
                            picList.push(partData.pic)
                        }

                        // 回显
                        // $("#addr").val(partData.addr);
                        $("#alumni_relation_persion").val(partData.alumni_relation_persion);
                        $("#amount").val(partData.amount)
                        $("#best_result").val(partData.best_result);
                        $("#birthday").val(partData.birthday);
                        $("#blood_type").val(partData.blood_type);
                        $("#clothing_size").val(partData.clothing_size);
                        $("#company_name").val(partData.company_name);
                        $("#company_position").val(partData.company_position);
                        $("#country").val(partData.country);
                        $("#run_team_name").val(partData.runTeamName);
                        $("#wx_number").val(partData.wx_number);

                        if (isNaN(partData.document_num)) {
                            $(".document_show").hide()
                        } else {
                            $("#document_num").val(partData.document_num);
                            $("#document_type").attr("data-values", partData.document_type);
                        }

                        $("#education").val(partData.education);
                        $("#email").val(partData.email);
                        $("#emergency_contact_mobile").val(partData.emergency_contact_mobile);
                        $("#emergency_contact_name").val(partData.emergency_contact_name);
                        $("#event_price_id").attr("data-values", partData.event_price_id);
                        $("#events_in_recent_year").val(partData.events_in_recent_year);
                        $("#name").val(partData.name);
                        $("#nation").val(partData.nation);
                        $("#nationality").val(partData.nationality);
                        $("#occupation").val(partData.occupation);
                        $("#passed_physical_exam").is(":checked") == true ? 1 : 0
                        $("#personal_mobile").val(partData.personal_mobile);
                        $("#training_mileage").val(partData.training_mileage);

                        if (partData.team_id == null) {
                            $("#x14").attr("checked", "checked")
                            $("#x15").removeAttr("checked")
                            $(".team_show").hide()
                            $("#")
                        } else {
                            $("#x15").attr("checked", "checked")
                            $("#x14").removeAttr("checked")
                            $(".team_show").show()

                        }

                        if (partData.online == 1) {
                            $("#x1").attr("checked", "checked")
                            $("#x2").removeAttr("checked")
                            $(".reference_show").hide()
                            $(".document_show").hide()
                            $(".wx_number_show").hide()
                            // $(".pca_show").hide()
                        } else {
                            $("#x1").removeAttr("checked")
                            $("#x2").attr("checked", "checked")
                            $(".reference_show").show()
                            $(".document_show").show()
                            $(".wx_number_show").show()
                            // $(".pca_show").show()
                        }


                        //todo 证件类型
                        if (partData.document_type == 1) {
                            $("#document_type").val("身份证")
                        }
                        if (partData.document_type == 2) {
                            $("#document_type").val("港澳通行证")
                        }
                        if (partData.document_type == 3) {
                            $("#document_type").val("护照")
                        }

                        //todo 性别
                        if (partData.sex == 1) {
                            $("#gender").val("男")
                        } else {
                            $("#gender").val("女")
                        }

                        var groupList = document.getElementsByName("group_id");
                        var group_id = partData.group_id;

                        for (var i = 0; i < groupList.length; i++) {
                            if ((groupList[i].value) != undefined) {
                                if (group_id == (groupList[i].value)) {
                                    groupList[i].checked = true;
                                }
                            }
                        }
                        param.groupId = group_id;

                        //角色
                        if (partData.role_id != null) {
                            $("#role_id").val(partData.role_name)
                            param.roleId = partData.role_id;
                        }
                        //团队
                        if (partData.team_id != null) {
                            $("#team_id").val(partData.team_name)
                            param.teamId = partData.team_id;
                        }
                        //套餐
                        if (partData.event_price_id != null) {
                            $("#event_price_id").val(partData.event_price_name)
                            param.eventPriceId = partData.event_price_id;
                        }
                        //校友会
                        if (partData.alumni_id != null) {
                            $("#alumni_id").val(partData.alumni_name)
                            param.alumniId = partData.alumni_id;
                        }

                        //邀请人
                        if (partData.reference != null) {
                            $("#reference").val(partData.reference)
                            param.reference = partData.reference;
                        }

                        //微信号
                        if (partData.wxNumber != null) {
                            $("#wx_number").val(partData.wxNumber)
                            param.wxNumber = partData.wxNumber;
                        }

                        //省市县
                        // $("#pca").val(partData.province + ' ' + partData.city + ' ' + partData.area)
                        // param.province = partData.province
                        // param.city = partData.city
                        // param.area = partData.area

                    }
                }
            }
        })
    }, 3000)

    var picList = [];

    $uploaderInput.on("change", function (e) {
        files = e.target.files;
        // 如果没有选中文件，直接返回
        if (files.length === 0) {
            return;
        }
        for (var i = 0, len = files.length; i < len; ++i) {
            var file = files[i];
            var imgID = genGUID();
            var reader = new FileReader();
            var fileType = file.type;
            // 如果类型不在允许的类型范围内
            if (allowTypes.indexOf(file.type) === -1) {

                $.toast('该类型不允许上传' + fileType, "forbidden");
                continue;
            }

            if (file.size > maxSize) {
                $.toast("图片太大，不允许上传", "forbidden");
                continue;
            }

            if ($('.weui-uploader__file').length >= maxCount) {
                $.toast('最多只能上传' + maxCount + '张图片', "forbidden");
                return;
            }


            reader.onload = function (e) {
                var img = new Image();
                img.onload = function () {
                    // 不要超出最大宽度
                    var w = Math.min(maxWidth, img.width);
                    // 高度按比例计算
                    var h = img.height * (w / img.width);
                    var canvas = document.createElement('canvas');
                    var ctx = canvas.getContext('2d');
                    // 设置 canvas 的宽度和高度
                    canvas.width = w;
                    canvas.height = h;
                    ctx.drawImage(img, 0, 0, w, h);
                    var base64 = canvas.toDataURL(fileType, 0.6); //0.6指的是压缩60%

                    // 插入到预览区
                    $uploaderFiles.append($(tmpl.replace('#url#', base64).replace('#ImgID#', imgID)));

                    var num = $('.weui-uploader__file').length;
                    $('#uploadCount').text(num);

                    // 模拟上传进度
                    var progress = 0;

                    function uploading() {
                        $uploaderFiles.find('.weui_uploader_status_content').text(++progress + '%');
                        if (progress < 100) {
                            setTimeout(uploading, 10);
                        } else {
                            $uploaderFiles.removeClass('weui_uploader_status').find('.weui_uploader_status_content').remove();//清除上传进度图标
                        }
                    }

                    setTimeout(uploading, 30);
                };

                img.src = e.target.result;
                picList.push(e.target.result)

            };
            reader.readAsDataURL(file);

        }
    });


    var index; //第几张图片
    $uploaderFiles.on("click", "li", function () {
        index = $(this).index();
        $galleryImg.attr("style", this.getAttribute("style"));
        $gallery.fadeIn(100);
    });
    $gallery.on("click", function () {
        $gallery.fadeOut(100);
    });

    //删除图片
    $(".weui-gallery__del").click(function () {
        console.log(picList);
        console.log(index);
        $uploaderFiles.find("li").eq(index).remove();
        picList.splice(index, 1);
        var num = $('.weui-uploader__file').length;
        $('#uploadCount').text(num);
        console.log(picList)
    });


    $("#btnsaveCharge").click(function () {


        //或者在这里实现批量上传, 不建议批量上传
    });

    //生成guid
    function genGUID() {
        var G1 = (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1) + (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
        var G2 = (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1) + (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
        return (G1 + G2);
    }


</script>
</html>
